/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.liang.gpio_demo;

import java.io.File;

/**
 * Class that provides access to some of the gpio management functions.
 *
 * {@hide}
 */
public class Gpio
{
	/*public Gpio(String path) {
		File gpio = new File(path);
		if (!gpio.canRead() || !gpio.canWrite()) {
			try {
				//通过挂在到linux的方式，修改文件的操作权限
				Process su = Runtime.getRuntime().exec("/system/bin/su");
				//一般的都是/system/bin/su路径，有的也是/system/xbin/su
				String cmd = "chmod 777 " + gpio.getAbsolutePath() + "\n" + "exit\n";
				su.getOutputStream().write(cmd.getBytes());

				if ((su.waitFor() != 0) || !gpio.canRead() || !gpio.canWrite()) {
					throw new SecurityException();
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new SecurityException();
			}
		}
	}*/

	// can't instantiate this class
	static {
		System.loadLibrary("gpio_jni");
       // System.loadLibrary("libstlport_shared");

	}


    public native int Set_GPIO();
	public native int Close_GPIO();
}

